package org.niu.array;

public class AddOne {
    public int[] plusOne(int[] digits) {
        int i = digits.length-1;
        for (i = digits.length-1;i>=0;i--){
            if (digits[i]!=9){
                digits[i]+=1;
                return digits;
            }else{
                digits[i]=0;
            }
        }

        int[] ans = new int[digits.length+1];

        ans[0]=1;
        return ans;
    }
}
